package com.chinasofti.treemap;

import java.util.Scanner;
import java.util.TreeMap;

public class Demo03 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一行字符串");
        String str = sc.nextLine();
        String [] strs = str.split("");
        TreeMap<String,Integer> treeMap = new TreeMap<>();
        for (String s : strs){
            if (!treeMap.containsKey(s)){
                treeMap.put(s,1);
            }else {
                treeMap.put(s,treeMap.get(s)+1);
            }
        }
        treeMap.forEach(
                (String k,Integer v)->{
                    System.out.print(k+"("+v+")");
                }
        );
    }
}
